# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=sps
pkgver=4.3
pkgrel=2
groups=('blackarch' 'blackarch-networking' 'blackarch-dos' 'blackarch-fuzzer')
pkgdesc='A Linux packet crafting tool. Supports IPv4, IPv6 including extension headers, and tunneling IPv6 over IPv4.'
arch=('x86_64')
url='https://sites.google.com/site/simplepacketsender/'
license=('GPL3')
depends=('gtk2' 'gtk3')
source=("https://sites.google.com/site/simplepacketsender/$pkgname-$pkgver.tar.gz")
sha512sums=('2e35bcc94137bb1cd6388c3e4ca7b560662726c55239fe511369941bc789327740f36cc307a0da4ddbe634d6a9e907024cf600db86f8b18f3d3d8cd24c2e1e9a')

build() {
  cd "$pkgname-$pkgver"

  case $CARCH in
    "x86_64") cd "$srcdir/sps-$pkgver/src64" ;;
    *) cd "$srcdir/sps-$pkgver/src32"
  esac

  make
}

package() {
  cd "$pkgname-$pkgver"

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  case $CARCH in
    "x86_64") cd "$srcdir/$pkgname-$pkgver/src64" ;;
    *) cd "$srcdir/$pkgname-$pkgver/src32"
  esac

  install -Dm 744 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"

  cp -a *.ui *.txt *.csv sps "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec ./$pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"

  chmod 644 "$pkgdir"/usr/share/sps/*.ui
  chmod 644 "$pkgdir"/usr/share/sps/*.txt
  chmod 644 "$pkgdir"/usr/share/sps/*.csv
}

